package com.zhong.system.service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhong.system.domain.SysUserPost;
import com.zhong.system.mapper.SysUserPostMapper;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
public class SysUserPostService extends ServiceImpl<SysUserPostMapper, SysUserPost> {

    public List<SysUserPost> findListByUserId(String userId){
        return list(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId,userId));
    }

    public int countByPostId(String postId){
        return count(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getPostId,postId));
    }

    public boolean removeByUserId(String userId){
        return remove(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId,userId));
    }

    public boolean removeByUserIds(String[] userIds){
        return remove(Wrappers.<SysUserPost>lambdaQuery().in(SysUserPost::getUserId, Arrays.asList(userIds)));
    }
}
